/*********************************************************************************
Organization 					: 				Georgia Institute of Technology
  
Institute 						:				Cognitive Computing Group(CCL)
 
Authors							: 				Santiago Ontanon
 												
Class							:				GoldCondition
 
Function						: 				Provides a class for holding 
												the gold condition class
****************************************************************************/
package planninglanguage.softconditions;

import mre.MRE;
import base.WargusGameState;


public class RelativeGoldSoftCondition extends SoftCondition {
	int m_minGold;
	int m_initialGold;
	
	public RelativeGoldSoftCondition(int a_minGold,int a_initialGold)
	{
		m_minGold = a_minGold;
		m_initialGold = a_minGold;
	}
	
	public String toString(int tabs) {
	  String n = super.toString(tabs);
	  n = n + "Min Gold is :" + m_minGold + "\n";
	  n = n + "Initial Gold is :" + m_initialGold;	  
	  return n;
	}	
	public float test(WargusGameState a_gameState)
	{
		if (a_gameState.getPlayer().getGold()-(MRE.allocated_gold+m_initialGold) >= m_minGold) {
			return 1.0f;
		} else {
			int progress = a_gameState.getPlayer().getGold()-(MRE.allocated_gold+m_initialGold);
			if (progress<0) progress=0;
			return ((float)progress)/((float)m_minGold);
		} // if		
	}
	
}
